namespace CShrpPro._1027;
public class Demo
{
    static void ()
    {
        // 测试抽象类
        UserTest userTest = new UserTestImpl();
        userTest.M1();
        userTest.M2();
        userTest.M3();

        // 测试接口
        UserService userService = new UserServiceImpl();
        userService.AddUser("张三");
        userService.QueryUser("张三");
        userService.UpdateUser("张三", "李四");
        userService.DeleteUser("李四");

        // 测试继承（正确类型转换）
        Father childObj = new Child();
        childObj.FatherMethod();
        if (childObj is Child child)
        {
            child.ChildMethod();
        }

        Father sonObj = new Son();
        sonObj.FatherMethod();
        if (sonObj is Son son)
        {
            son.SonMethod();
        }

        // 测试 Student 类
        Student stu = new Student { Name = "王五", Age = 20 };
        stu.Study();

        // 测试方法重载（私有方法，仅内部调用）
        Demo demo = new Demo();
        Console.WriteLine("整数相加：" + demo.Add(10, 20));
        Console.WriteLine("小数相加：" + demo.Add(10.5, 20.5));
    }

    // 方法重载：设为私有，符合封装原则
    private int Add(int a, int b) => a + b;
    private double Add(double a, double b) => a + b;
}